package com.jiazhong.多态and转型.Instanceof;
//instanceof用于判断对象的运行内存是否为xx类型或xx类型的子类
public class PolyDetail {
    public static void main(String[] args) {
        B b=new B();
        System.out.println(b instanceof B);//true
        System.out.println(b instanceof A);//true

        A a=new B();
        System.out.println(a instanceof A);
        System.out.println(a instanceof B);

        Object obj=new Object();
        System.out.println(obj instanceof A);//false
        System.out.println(obj instanceof B);//false
        System.out.println(a instanceof Object);
        String str="hello";
        //System.out.println(str instanceof A);
        System.out.println(str instanceof Object);//true
    }
}
class A{
    //父类
}
class B extends A{
    //子类
}
